package com.spider.demo2threadapi;

public class ThreadApiDemo3 {
    public static void main(String[] args) {
        //目标：搞清楚线程的Join方法：线程插队，让调用这个方法的线程先执行完。
        Thread t1 = new Thread(() -> {
            for (int i = 0; i < 20; i++) {
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println(Thread.currentThread().getName()+":  " + i);
            }
        });
        t1.start();
        try {
            t1.join();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        for (int i = 0; i < 20; i++) {
            System.out.println(Thread.currentThread().getName()+":  " + i);
        }
    }
}
